home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
MATHS
/
RLAB
/
RLAB125.ZIP
/
!RLaB
/
help_sz
/
static
< prev
next >
Wrap
Text File
|
1994-09-21
|
1KB
|
39 lines
static:
Syntax: static ( VAR1 , VAR2 , VAR3, ... )
Description:
The static declaration is used to protect the specified
variables within the scope of a file. There are no
restrictions on where or how many static declarations can
occur. Static declarations only affect statements after the
declaration. Static variables are not visible to statements or
functions outside of the file in which they are created.
Since all input to RLaB is treated as originating from a file
(stdin, for example), static variables can be used from the
command line to protect variables from functions if
necessary. For example:
> // From the command line
> static (pi)
> pi = 12;
> load ("./jnk.r");
> system ("cat jnk.r");
x = function ( )
{
global (pi)
pi = -atan(1.0)*4;
};
> x();
> pi
pi =
12
As you can see `pi' is declared global within the function
`x'. In spite of the global declaration, `x', because it was
created from within another file, cannot modify `pi'.
See Also: FUNCTION, global, local